<?php
	/**
	 * The abstract ArticlecoreGen class defined here is
	 * code-generated and contains all the basic CRUD-type functionality as well as
	 * basic methods to handle relationships and index-based loading.
	 *
	 * To use, you should use the Articlecore subclass which
	 * extends this ArticlecoreGen class.
	 *
	 * Because subsequent re-code generations will overwrite any changes to this
	 * file, you should leave this file unaltered to prevent yourself from losing
	 * any information or code changes.  All customizations should be done by
	 * overriding existing or implementing new methods, properties and variables
	 * in the Articlecore class.
	 * 
	 * @package My Application
	 * @subpackage GeneratedDataObjects
	 * @property-read integer $Id the value for intId (Read-Only PK)
	 * @property string $Asin the value for strAsin 
	 * @property string $DetailPageURL the value for strDetailPageURL 
	 * @property string $Binding the value for strBinding 
	 * @property string $Title the value for strTitle 
	 * @property integer $ProductGroup the value for intProductGroup 
	 * @property string $ImageURL the value for strImageURL 
	 * @property Articlecategory $ProductGroupObject the value for the Articlecategory object referenced by intProductGroup 
	 * @property-read Articlebook $_ArticlebookAsReferenceID the value for the private _objArticlebookAsReferenceID (Read-Only) if set due to an expansion on the articlebook.ReferenceID reverse relationship
	 * @property-read Articlebook[] $_ArticlebookAsReferenceIDArray the value for the private _objArticlebookAsReferenceIDArray (Read-Only) if set due to an ExpandAsArray on the articlebook.ReferenceID reverse relationship
	 * @property-read Articlemovies $_ArticlemoviesAsReferenceID the value for the private _objArticlemoviesAsReferenceID (Read-Only) if set due to an expansion on the articlemovies.ReferenceID reverse relationship
	 * @property-read Articlemovies[] $_ArticlemoviesAsReferenceIDArray the value for the private _objArticlemoviesAsReferenceIDArray (Read-Only) if set due to an ExpandAsArray on the articlemovies.ReferenceID reverse relationship
	 * @property-read Articlemusic $_ArticlemusicAsReferenceID the value for the private _objArticlemusicAsReferenceID (Read-Only) if set due to an expansion on the articlemusic.ReferenceID reverse relationship
	 * @property-read Articlemusic[] $_ArticlemusicAsReferenceIDArray the value for the private _objArticlemusicAsReferenceIDArray (Read-Only) if set due to an ExpandAsArray on the articlemusic.ReferenceID reverse relationship
	 * @property-read boolean $__Restored whether or not this object was restored from the database (as opposed to created new)
	 */
	class ArticlecoreGen extends QBaseClass {

		///////////////////////////////////////////////////////////////////////
		// PROTECTED MEMBER VARIABLES and TEXT FIELD MAXLENGTHS (if applicable)
		///////////////////////////////////////////////////////////////////////
		
		/**
		 * Protected member variable that maps to the database PK Identity column articlecore.id
		 * @var integer intId
		 */
		protected $intId;
		const IdDefault = null;


		/**
		 * Protected member variable that maps to the database column articlecore.ASIN
		 * @var string strAsin
		 */
		protected $strAsin;
		const AsinMaxLength = 10;
		const AsinDefault = null;


		/**
		 * Protected member variable that maps to the database column articlecore.DetailPageURL
		 * @var string strDetailPageURL
		 */
		protected $strDetailPageURL;
		const DetailPageURLMaxLength = 255;
		const DetailPageURLDefault = null;


		/**
		 * Protected member variable that maps to the database column articlecore.Binding
		 * @var string strBinding
		 */
		protected $strBinding;
		const BindingMaxLength = 50;
		const BindingDefault = null;


		/**
		 * Protected member variable that maps to the database column articlecore.Title
		 * @var string strTitle
		 */
		protected $strTitle;
		const TitleMaxLength = 255;
		const TitleDefault = null;


		/**
		 * Protected member variable that maps to the database column articlecore.ProductGroup
		 * @var integer intProductGroup
		 */
		protected $intProductGroup;
		const ProductGroupDefault = null;


		/**
		 * Protected member variable that maps to the database column articlecore.ImageURL
		 * @var string strImageURL
		 */
		protected $strImageURL;
		const ImageURLDefault = null;


		/**
		 * Private member variable that stores a reference to a single ArticlebookAsReferenceID object
		 * (of type Articlebook), if this Articlecore object was restored with
		 * an expansion on the articlebook association table.
		 * @var Articlebook _objArticlebookAsReferenceID;
		 */
		private $_objArticlebookAsReferenceID;

		/**
		 * Private member variable that stores a reference to an array of ArticlebookAsReferenceID objects
		 * (of type Articlebook[]), if this Articlecore object was restored with
		 * an ExpandAsArray on the articlebook association table.
		 * @var Articlebook[] _objArticlebookAsReferenceIDArray;
		 */
		private $_objArticlebookAsReferenceIDArray = array();

		/**
		 * Private member variable that stores a reference to a single ArticlemoviesAsReferenceID object
		 * (of type Articlemovies), if this Articlecore object was restored with
		 * an expansion on the articlemovies association table.
		 * @var Articlemovies _objArticlemoviesAsReferenceID;
		 */
		private $_objArticlemoviesAsReferenceID;

		/**
		 * Private member variable that stores a reference to an array of ArticlemoviesAsReferenceID objects
		 * (of type Articlemovies[]), if this Articlecore object was restored with
		 * an ExpandAsArray on the articlemovies association table.
		 * @var Articlemovies[] _objArticlemoviesAsReferenceIDArray;
		 */
		private $_objArticlemoviesAsReferenceIDArray = array();

		/**
		 * Private member variable that stores a reference to a single ArticlemusicAsReferenceID object
		 * (of type Articlemusic), if this Articlecore object was restored with
		 * an expansion on the articlemusic association table.
		 * @var Articlemusic _objArticlemusicAsReferenceID;
		 */
		private $_objArticlemusicAsReferenceID;

		/**
		 * Private member variable that stores a reference to an array of ArticlemusicAsReferenceID objects
		 * (of type Articlemusic[]), if this Articlecore object was restored with
		 * an ExpandAsArray on the articlemusic association table.
		 * @var Articlemusic[] _objArticlemusicAsReferenceIDArray;
		 */
		private $_objArticlemusicAsReferenceIDArray = array();

		/**
		 * Protected array of virtual attributes for this object (e.g. extra/other calculated and/or non-object bound
		 * columns from the run-time database query result for this object).  Used by InstantiateDbRow and
		 * GetVirtualAttribute.
		 * @var string[] $__strVirtualAttributeArray
		 */
		protected $__strVirtualAttributeArray = array();

		/**
		 * Protected internal member variable that specifies whether or not this object is Restored from the database.
		 * Used by Save() to determine if Save() should perform a db UPDATE or INSERT.
		 * @var bool __blnRestored;
		 */
		protected $__blnRestored;




		///////////////////////////////
		// PROTECTED MEMBER OBJECTS
		///////////////////////////////

		/**
		 * Protected member variable that contains the object pointed by the reference
		 * in the database column articlecore.ProductGroup.
		 *
		 * NOTE: Always use the ProductGroupObject property getter to correctly retrieve this Articlecategory object.
		 * (Because this class implements late binding, this variable reference MAY be null.)
		 * @var Articlecategory objProductGroupObject
		 */
		protected $objProductGroupObject;





		///////////////////////////////
		// CLASS-WIDE LOAD AND COUNT METHODS
		///////////////////////////////

		/**
		 * Static method to retrieve the Database object that owns this class.
		 * @return QDatabaseBase reference to the Database object that can query this class
		 */
		public static function GetDatabase() {
			return QApplication::$Database[1];
		}

		/**
		 * Load a Articlecore from PK Info
		 * @param integer $intId
		 * @return Articlecore
		 */
		public static function Load($intId) {
			// Use QuerySingle to Perform the Query
			return Articlecore::QuerySingle(
				QQ::Equal(QQN::Articlecore()->Id, $intId)
			);
		}

		/**
		 * Load all Articlecores
		 * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
		 * @return Articlecore[]
		 */
		public static function LoadAll($objOptionalClauses = null) {
			// Call Articlecore::QueryArray to perform the LoadAll query
			try {
				return Articlecore::QueryArray(QQ::All(), $objOptionalClauses);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}

		/**
		 * Count all Articlecores
		 * @return int
		 */
		public static function CountAll() {
			// Call Articlecore::QueryCount to perform the CountAll query
			return Articlecore::QueryCount(QQ::All());
		}




		///////////////////////////////
		// QCODO QUERY-RELATED METHODS
		///////////////////////////////

		/**
		 * Internally called method to assist with calling Qcodo Query for this class
		 * on load methods.
		 * @param QQueryBuilder &$objQueryBuilder the QueryBuilder object that will be created
		 * @param QQCondition $objConditions any conditions on the query, itself
		 * @param QQClause[] $objOptionalClausees additional optional QQClause object or array of QQClause objects for this query
		 * @param mixed[] $mixParameterArray a array of name-value pairs to perform PrepareStatement with (sending in null will skip the PrepareStatement step)
		 * @param boolean $blnCountOnly only select a rowcount
		 * @return string the query statement
		 */
		protected static function BuildQueryStatement(&$objQueryBuilder, QQCondition $objConditions, $objOptionalClauses, $mixParameterArray, $blnCountOnly) {
			// Get the Database Object for this Class
			$objDatabase = Articlecore::GetDatabase();

			// Create/Build out the QueryBuilder object with Articlecore-specific SELET and FROM fields
			$objQueryBuilder = new QQueryBuilder($objDatabase, 'articlecore');
			Articlecore::GetSelectFields($objQueryBuilder);
			$objQueryBuilder->AddFromItem('articlecore');

			// Set "CountOnly" option (if applicable)
			if ($blnCountOnly)
				$objQueryBuilder->SetCountOnlyFlag();

			// Apply Any Conditions
			if ($objConditions)
				try {
					$objConditions->UpdateQueryBuilder($objQueryBuilder);
				} catch (QCallerException $objExc) {
					$objExc->IncrementOffset();
					throw $objExc;
				}

			// Iterate through all the Optional Clauses (if any) and perform accordingly
			if ($objOptionalClauses) {
				if ($objOptionalClauses instanceof QQClause)
					$objOptionalClauses->UpdateQueryBuilder($objQueryBuilder);
				else if (is_array($objOptionalClauses))
					foreach ($objOptionalClauses as $objClause)
						$objClause->UpdateQueryBuilder($objQueryBuilder);
				else
					throw new QCallerException('Optional Clauses must be a QQClause object or an array of QQClause objects');
			}

			// Get the SQL Statement
			$strQuery = $objQueryBuilder->GetStatement();

			// Prepare the Statement with the Query Parameters (if applicable)
			if ($mixParameterArray) {
				if (is_array($mixParameterArray)) {
					if (count($mixParameterArray))
						$strQuery = $objDatabase->PrepareStatement($strQuery, $mixParameterArray);

					// Ensure that there are no other Unresolved Named Parameters
					if (strpos($strQuery, chr(QQNamedValue::DelimiterCode) . '{') !== false)
						throw new QCallerException('Unresolved named parameters in the query');
				} else
					throw new QCallerException('Parameter Array must be an array of name-value parameter pairs');
			}

			// Return the Objects
			return $strQuery;
		}

		/**
		 * Static Qcodo Query method to query for a single Articlecore object.
		 * Uses BuildQueryStatment to perform most of the work.
		 * @param QQCondition $objConditions any conditions on the query, itself
		 * @param QQClause[] $objOptionalClausees additional optional QQClause objects for this query
		 * @param mixed[] $mixParameterArray a array of name-value pairs to perform PrepareStatement with
		 * @return Articlecore the queried object
		 */
		public static function QuerySingle(QQCondition $objConditions, $objOptionalClauses = null, $mixParameterArray = null) {
			// Get the Query Statement
			try {
				$strQuery = Articlecore::BuildQueryStatement($objQueryBuilder, $objConditions, $objOptionalClauses, $mixParameterArray, false);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}

			// Perform the Query, Get the First Row, and Instantiate a new Articlecore object
			$objDbResult = $objQueryBuilder->Database->Query($strQuery);
			return Articlecore::InstantiateDbRow($objDbResult->GetNextRow(), null, null, null, $objQueryBuilder->ColumnAliasArray);
		}

		/**
		 * Static Qcodo Query method to query for an array of Articlecore objects.
		 * Uses BuildQueryStatment to perform most of the work.
		 * @param QQCondition $objConditions any conditions on the query, itself
		 * @param QQClause[] $objOptionalClausees additional optional QQClause objects for this query
		 * @param mixed[] $mixParameterArray a array of name-value pairs to perform PrepareStatement with
		 * @return Articlecore[] the queried objects as an array
		 */
		public static function QueryArray(QQCondition $objConditions, $objOptionalClauses = null, $mixParameterArray = null) {
			// Get the Query Statement
			try {
				$strQuery = Articlecore::BuildQueryStatement($objQueryBuilder, $objConditions, $objOptionalClauses, $mixParameterArray, false);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}

			// Perform the Query and Instantiate the Array Result
			$objDbResult = $objQueryBuilder->Database->Query($strQuery);
			return Articlecore::InstantiateDbResult($objDbResult, $objQueryBuilder->ExpandAsArrayNodes, $objQueryBuilder->ColumnAliasArray);
		}

		/**
		 * Static Qcodo Query method to query for a count of Articlecore objects.
		 * Uses BuildQueryStatment to perform most of the work.
		 * @param QQCondition $objConditions any conditions on the query, itself
		 * @param QQClause[] $objOptionalClausees additional optional QQClause objects for this query
		 * @param mixed[] $mixParameterArray a array of name-value pairs to perform PrepareStatement with
		 * @return integer the count of queried objects as an integer
		 */
		public static function QueryCount(QQCondition $objConditions, $objOptionalClauses = null, $mixParameterArray = null) {
			// Get the Query Statement
			try {
				$strQuery = Articlecore::BuildQueryStatement($objQueryBuilder, $objConditions, $objOptionalClauses, $mixParameterArray, true);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}

			// Perform the Query and return the row_count
			$objDbResult = $objQueryBuilder->Database->Query($strQuery);

			// Figure out if the query is using GroupBy
			$blnGrouped = false;

			if ($objOptionalClauses) foreach ($objOptionalClauses as $objClause) {
				if ($objClause instanceof QQGroupBy) {
					$blnGrouped = true;
					break;
				}
			}

			if ($blnGrouped)
				// Groups in this query - return the count of Groups (which is the count of all rows)
				return $objDbResult->CountRows();
			else {
				// No Groups - return the sql-calculated count(*) value
				$strDbRow = $objDbResult->FetchRow();
				return QType::Cast($strDbRow[0], QType::Integer);
			}
		}

/*		public static function QueryArrayCached($strConditions, $mixParameterArray = null) {
			// Get the Database Object for this Class
			$objDatabase = Articlecore::GetDatabase();

			// Lookup the QCache for This Query Statement
			$objCache = new QCache('query', 'articlecore_' . serialize($strConditions));
			if (!($strQuery = $objCache->GetData())) {
				// Not Found -- Go ahead and Create/Build out a new QueryBuilder object with Articlecore-specific fields
				$objQueryBuilder = new QQueryBuilder($objDatabase);
				Articlecore::GetSelectFields($objQueryBuilder);
				Articlecore::GetFromFields($objQueryBuilder);

				// Ensure the Passed-in Conditions is a string
				try {
					$strConditions = QType::Cast($strConditions, QType::String);
				} catch (QCallerException $objExc) {
					$objExc->IncrementOffset();
					throw $objExc;
				}

				// Create the Conditions object, and apply it
				$objConditions = eval('return ' . $strConditions . ';');

				// Apply Any Conditions
				if ($objConditions)
					$objConditions->UpdateQueryBuilder($objQueryBuilder);

				// Get the SQL Statement
				$strQuery = $objQueryBuilder->GetStatement();

				// Save the SQL Statement in the Cache
				$objCache->SaveData($strQuery);
			}

			// Prepare the Statement with the Parameters
			if ($mixParameterArray)
				$strQuery = $objDatabase->PrepareStatement($strQuery, $mixParameterArray);

			// Perform the Query and Instantiate the Array Result
			$objDbResult = $objDatabase->Query($strQuery);
			return Articlecore::InstantiateDbResult($objDbResult);
		}*/

		/**
		 * Updates a QQueryBuilder with the SELECT fields for this Articlecore
		 * @param QQueryBuilder $objBuilder the Query Builder object to update
		 * @param string $strPrefix optional prefix to add to the SELECT fields
		 */
		public static function GetSelectFields(QQueryBuilder $objBuilder, $strPrefix = null) {
			if ($strPrefix) {
				$strTableName = $strPrefix;
				$strAliasPrefix = $strPrefix . '__';
			} else {
				$strTableName = 'articlecore';
				$strAliasPrefix = '';
			}

			$objBuilder->AddSelectItem($strTableName, 'id', $strAliasPrefix . 'id');
			$objBuilder->AddSelectItem($strTableName, 'ASIN', $strAliasPrefix . 'ASIN');
			$objBuilder->AddSelectItem($strTableName, 'DetailPageURL', $strAliasPrefix . 'DetailPageURL');
			$objBuilder->AddSelectItem($strTableName, 'Binding', $strAliasPrefix . 'Binding');
			$objBuilder->AddSelectItem($strTableName, 'Title', $strAliasPrefix . 'Title');
			$objBuilder->AddSelectItem($strTableName, 'ProductGroup', $strAliasPrefix . 'ProductGroup');
			$objBuilder->AddSelectItem($strTableName, 'ImageURL', $strAliasPrefix . 'ImageURL');
		}




		///////////////////////////////
		// INSTANTIATION-RELATED METHODS
		///////////////////////////////

		/**
		 * Instantiate a Articlecore from a Database Row.
		 * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow
		 * is calling this Articlecore::InstantiateDbRow in order to perform
		 * early binding on referenced objects.
		 * @param DatabaseRowBase $objDbRow
		 * @param string $strAliasPrefix
		 * @param string $strExpandAsArrayNodes
		 * @param QBaseClass $objPreviousItem
		 * @param string[] $strColumnAliasArray
		 * @return Articlecore
		*/
		public static function InstantiateDbRow($objDbRow, $strAliasPrefix = null, $strExpandAsArrayNodes = null, $objPreviousItem = null, $strColumnAliasArray = array()) {
			// If blank row, return null
			if (!$objDbRow)
				return null;

			// See if we're doing an array expansion on the previous item
			$strAlias = $strAliasPrefix . 'id';
			$strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
			if (($strExpandAsArrayNodes) && ($objPreviousItem) &&
				($objPreviousItem->intId == $objDbRow->GetColumn($strAliasName, 'Integer'))) {

				// We are.  Now, prepare to check for ExpandAsArray clauses
				$blnExpandedViaArray = false;
				if (!$strAliasPrefix)
					$strAliasPrefix = 'articlecore__';


				$strAlias = $strAliasPrefix . 'articlebookasreferenceid__id';
				$strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
				if ((array_key_exists($strAlias, $strExpandAsArrayNodes)) &&
					(!is_null($objDbRow->GetColumn($strAliasName)))) {
					if ($intPreviousChildItemCount = count($objPreviousItem->_objArticlebookAsReferenceIDArray)) {
						$objPreviousChildItem = $objPreviousItem->_objArticlebookAsReferenceIDArray[$intPreviousChildItemCount - 1];
						$objChildItem = Articlebook::InstantiateDbRow($objDbRow, $strAliasPrefix . 'articlebookasreferenceid__', $strExpandAsArrayNodes, $objPreviousChildItem, $strColumnAliasArray);
						if ($objChildItem)
							$objPreviousItem->_objArticlebookAsReferenceIDArray[] = $objChildItem;
					} else
						$objPreviousItem->_objArticlebookAsReferenceIDArray[] = Articlebook::InstantiateDbRow($objDbRow, $strAliasPrefix . 'articlebookasreferenceid__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
					$blnExpandedViaArray = true;
				}

				$strAlias = $strAliasPrefix . 'articlemoviesasreferenceid__id';
				$strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
				if ((array_key_exists($strAlias, $strExpandAsArrayNodes)) &&
					(!is_null($objDbRow->GetColumn($strAliasName)))) {
					if ($intPreviousChildItemCount = count($objPreviousItem->_objArticlemoviesAsReferenceIDArray)) {
						$objPreviousChildItem = $objPreviousItem->_objArticlemoviesAsReferenceIDArray[$intPreviousChildItemCount - 1];
						$objChildItem = Articlemovies::InstantiateDbRow($objDbRow, $strAliasPrefix . 'articlemoviesasreferenceid__', $strExpandAsArrayNodes, $objPreviousChildItem, $strColumnAliasArray);
						if ($objChildItem)
							$objPreviousItem->_objArticlemoviesAsReferenceIDArray[] = $objChildItem;
					} else
						$objPreviousItem->_objArticlemoviesAsReferenceIDArray[] = Articlemovies::InstantiateDbRow($objDbRow, $strAliasPrefix . 'articlemoviesasreferenceid__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
					$blnExpandedViaArray = true;
				}

				$strAlias = $strAliasPrefix . 'articlemusicasreferenceid__id';
				$strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
				if ((array_key_exists($strAlias, $strExpandAsArrayNodes)) &&
					(!is_null($objDbRow->GetColumn($strAliasName)))) {
					if ($intPreviousChildItemCount = count($objPreviousItem->_objArticlemusicAsReferenceIDArray)) {
						$objPreviousChildItem = $objPreviousItem->_objArticlemusicAsReferenceIDArray[$intPreviousChildItemCount - 1];
						$objChildItem = Articlemusic::InstantiateDbRow($objDbRow, $strAliasPrefix . 'articlemusicasreferenceid__', $strExpandAsArrayNodes, $objPreviousChildItem, $strColumnAliasArray);
						if ($objChildItem)
							$objPreviousItem->_objArticlemusicAsReferenceIDArray[] = $objChildItem;
					} else
						$objPreviousItem->_objArticlemusicAsReferenceIDArray[] = Articlemusic::InstantiateDbRow($objDbRow, $strAliasPrefix . 'articlemusicasreferenceid__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
					$blnExpandedViaArray = true;
				}

				// Either return false to signal array expansion, or check-to-reset the Alias prefix and move on
				if ($blnExpandedViaArray)
					return false;
				else if ($strAliasPrefix == 'articlecore__')
					$strAliasPrefix = null;
			}

			// Create a new instance of the Articlecore object
			$objToReturn = new Articlecore();
			$objToReturn->__blnRestored = true;

			$strAliasName = array_key_exists($strAliasPrefix . 'id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'id'] : $strAliasPrefix . 'id';
			$objToReturn->intId = $objDbRow->GetColumn($strAliasName, 'Integer');
			$strAliasName = array_key_exists($strAliasPrefix . 'ASIN', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'ASIN'] : $strAliasPrefix . 'ASIN';
			$objToReturn->strAsin = $objDbRow->GetColumn($strAliasName, 'VarChar');
			$strAliasName = array_key_exists($strAliasPrefix . 'DetailPageURL', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'DetailPageURL'] : $strAliasPrefix . 'DetailPageURL';
			$objToReturn->strDetailPageURL = $objDbRow->GetColumn($strAliasName, 'VarChar');
			$strAliasName = array_key_exists($strAliasPrefix . 'Binding', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'Binding'] : $strAliasPrefix . 'Binding';
			$objToReturn->strBinding = $objDbRow->GetColumn($strAliasName, 'VarChar');
			$strAliasName = array_key_exists($strAliasPrefix . 'Title', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'Title'] : $strAliasPrefix . 'Title';
			$objToReturn->strTitle = $objDbRow->GetColumn($strAliasName, 'VarChar');
			$strAliasName = array_key_exists($strAliasPrefix . 'ProductGroup', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'ProductGroup'] : $strAliasPrefix . 'ProductGroup';
			$objToReturn->intProductGroup = $objDbRow->GetColumn($strAliasName, 'Integer');
			$strAliasName = array_key_exists($strAliasPrefix . 'ImageURL', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'ImageURL'] : $strAliasPrefix . 'ImageURL';
			$objToReturn->strImageURL = $objDbRow->GetColumn($strAliasName, 'Blob');

			// Instantiate Virtual Attributes
			foreach ($objDbRow->GetColumnNameArray() as $strColumnName => $mixValue) {
				$strVirtualPrefix = $strAliasPrefix . '__';
				$strVirtualPrefixLength = strlen($strVirtualPrefix);
				if (substr($strColumnName, 0, $strVirtualPrefixLength) == $strVirtualPrefix)
					$objToReturn->__strVirtualAttributeArray[substr($strColumnName, $strVirtualPrefixLength)] = $mixValue;
			}

			// Prepare to Check for Early/Virtual Binding
			if (!$strAliasPrefix)
				$strAliasPrefix = 'articlecore__';

			// Check for ProductGroupObject Early Binding
			$strAlias = $strAliasPrefix . 'ProductGroup__id';
			$strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
			if (!is_null($objDbRow->GetColumn($strAliasName)))
				$objToReturn->objProductGroupObject = Articlecategory::InstantiateDbRow($objDbRow, $strAliasPrefix . 'ProductGroup__', $strExpandAsArrayNodes, null, $strColumnAliasArray);




			// Check for ArticlebookAsReferenceID Virtual Binding
			$strAlias = $strAliasPrefix . 'articlebookasreferenceid__id';
			$strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
			if (!is_null($objDbRow->GetColumn($strAliasName))) {
				if (($strExpandAsArrayNodes) && (array_key_exists($strAlias, $strExpandAsArrayNodes)))
					$objToReturn->_objArticlebookAsReferenceIDArray[] = Articlebook::InstantiateDbRow($objDbRow, $strAliasPrefix . 'articlebookasreferenceid__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
				else
					$objToReturn->_objArticlebookAsReferenceID = Articlebook::InstantiateDbRow($objDbRow, $strAliasPrefix . 'articlebookasreferenceid__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
			}

			// Check for ArticlemoviesAsReferenceID Virtual Binding
			$strAlias = $strAliasPrefix . 'articlemoviesasreferenceid__id';
			$strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
			if (!is_null($objDbRow->GetColumn($strAliasName))) {
				if (($strExpandAsArrayNodes) && (array_key_exists($strAlias, $strExpandAsArrayNodes)))
					$objToReturn->_objArticlemoviesAsReferenceIDArray[] = Articlemovies::InstantiateDbRow($objDbRow, $strAliasPrefix . 'articlemoviesasreferenceid__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
				else
					$objToReturn->_objArticlemoviesAsReferenceID = Articlemovies::InstantiateDbRow($objDbRow, $strAliasPrefix . 'articlemoviesasreferenceid__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
			}

			// Check for ArticlemusicAsReferenceID Virtual Binding
			$strAlias = $strAliasPrefix . 'articlemusicasreferenceid__id';
			$strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
			if (!is_null($objDbRow->GetColumn($strAliasName))) {
				if (($strExpandAsArrayNodes) && (array_key_exists($strAlias, $strExpandAsArrayNodes)))
					$objToReturn->_objArticlemusicAsReferenceIDArray[] = Articlemusic::InstantiateDbRow($objDbRow, $strAliasPrefix . 'articlemusicasreferenceid__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
				else
					$objToReturn->_objArticlemusicAsReferenceID = Articlemusic::InstantiateDbRow($objDbRow, $strAliasPrefix . 'articlemusicasreferenceid__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
			}

			return $objToReturn;
		}

		/**
		 * Instantiate an array of Articlecores from a Database Result
		 * @param DatabaseResultBase $objDbResult
		 * @param string $strExpandAsArrayNodes
		 * @param string[] $strColumnAliasArray
		 * @return Articlecore[]
		 */
		public static function InstantiateDbResult(QDatabaseResultBase $objDbResult, $strExpandAsArrayNodes = null, $strColumnAliasArray = null) {
			$objToReturn = array();
			
			if (!$strColumnAliasArray)
				$strColumnAliasArray = array();

			// If blank resultset, then return empty array
			if (!$objDbResult)
				return $objToReturn;

			// Load up the return array with each row
			if ($strExpandAsArrayNodes) {
				$objLastRowItem = null;
				while ($objDbRow = $objDbResult->GetNextRow()) {
					$objItem = Articlecore::InstantiateDbRow($objDbRow, null, $strExpandAsArrayNodes, $objLastRowItem, $strColumnAliasArray);
					if ($objItem) {
						$objToReturn[] = $objItem;
						$objLastRowItem = $objItem;
					}
				}
			} else {
				while ($objDbRow = $objDbResult->GetNextRow())
					$objToReturn[] = Articlecore::InstantiateDbRow($objDbRow, null, null, null, $strColumnAliasArray);
			}

			return $objToReturn;
		}




		///////////////////////////////////////////////////
		// INDEX-BASED LOAD METHODS (Single Load and Array)
		///////////////////////////////////////////////////
			
		/**
		 * Load a single Articlecore object,
		 * by Id Index(es)
		 * @param integer $intId
		 * @return Articlecore
		*/
		public static function LoadById($intId) {
			return Articlecore::QuerySingle(
				QQ::Equal(QQN::Articlecore()->Id, $intId)
			);
		}
			
		/**
		 * Load an array of Articlecore objects,
		 * by ProductGroup Index(es)
		 * @param integer $intProductGroup
		 * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
		 * @return Articlecore[]
		*/
		public static function LoadArrayByProductGroup($intProductGroup, $objOptionalClauses = null) {
			// Call Articlecore::QueryArray to perform the LoadArrayByProductGroup query
			try {
				return Articlecore::QueryArray(
					QQ::Equal(QQN::Articlecore()->ProductGroup, $intProductGroup),
					$objOptionalClauses);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}

		/**
		 * Count Articlecores
		 * by ProductGroup Index(es)
		 * @param integer $intProductGroup
		 * @return int
		*/
		public static function CountByProductGroup($intProductGroup) {
			// Call Articlecore::QueryCount to perform the CountByProductGroup query
			return Articlecore::QueryCount(
				QQ::Equal(QQN::Articlecore()->ProductGroup, $intProductGroup)
			);
		}



		////////////////////////////////////////////////////
		// INDEX-BASED LOAD METHODS (Array via Many to Many)
		////////////////////////////////////////////////////




		//////////////////////////
		// SAVE, DELETE AND RELOAD
		//////////////////////////

		/**
		 * Save this Articlecore
		 * @param bool $blnForceInsert
		 * @param bool $blnForceUpdate
		 * @return int
		 */
		public function Save($blnForceInsert = false, $blnForceUpdate = false) {
			// Get the Database Object for this Class
			$objDatabase = Articlecore::GetDatabase();

			$mixToReturn = null;

			try {
				if ((!$this->__blnRestored) || ($blnForceInsert)) {
					// Perform an INSERT query
					$objDatabase->NonQuery('
						INSERT INTO `articlecore` (
							`ASIN`,
							`DetailPageURL`,
							`Binding`,
							`Title`,
							`ProductGroup`,
							`ImageURL`
						) VALUES (
							' . $objDatabase->SqlVariable($this->strAsin) . ',
							' . $objDatabase->SqlVariable($this->strDetailPageURL) . ',
							' . $objDatabase->SqlVariable($this->strBinding) . ',
							' . $objDatabase->SqlVariable($this->strTitle) . ',
							' . $objDatabase->SqlVariable($this->intProductGroup) . ',
							' . $objDatabase->SqlVariable($this->strImageURL) . '
						)
					');

					// Update Identity column and return its value
					$mixToReturn = $this->intId = $objDatabase->InsertId('articlecore', 'id');
				} else {
					// Perform an UPDATE query

					// First checking for Optimistic Locking constraints (if applicable)

					// Perform the UPDATE query
					$objDatabase->NonQuery('
						UPDATE
							`articlecore`
						SET
							`ASIN` = ' . $objDatabase->SqlVariable($this->strAsin) . ',
							`DetailPageURL` = ' . $objDatabase->SqlVariable($this->strDetailPageURL) . ',
							`Binding` = ' . $objDatabase->SqlVariable($this->strBinding) . ',
							`Title` = ' . $objDatabase->SqlVariable($this->strTitle) . ',
							`ProductGroup` = ' . $objDatabase->SqlVariable($this->intProductGroup) . ',
							`ImageURL` = ' . $objDatabase->SqlVariable($this->strImageURL) . '
						WHERE
							`id` = ' . $objDatabase->SqlVariable($this->intId) . '
					');
				}

			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}

			// Update __blnRestored and any Non-Identity PK Columns (if applicable)
			$this->__blnRestored = true;


			// Return 
			return $mixToReturn;
		}

		/**
		 * Delete this Articlecore
		 * @return void
		 */
		public function Delete() {
			if ((is_null($this->intId)))
				throw new QUndefinedPrimaryKeyException('Cannot delete this Articlecore with an unset primary key.');

			// Get the Database Object for this Class
			$objDatabase = Articlecore::GetDatabase();


			// Perform the SQL Query
			$objDatabase->NonQuery('
				DELETE FROM
					`articlecore`
				WHERE
					`id` = ' . $objDatabase->SqlVariable($this->intId) . '');
		}

		/**
		 * Delete all Articlecores
		 * @return void
		 */
		public static function DeleteAll() {
			// Get the Database Object for this Class
			$objDatabase = Articlecore::GetDatabase();

			// Perform the Query
			$objDatabase->NonQuery('
				DELETE FROM
					`articlecore`');
		}

		/**
		 * Truncate articlecore table
		 * @return void
		 */
		public static function Truncate() {
			// Get the Database Object for this Class
			$objDatabase = Articlecore::GetDatabase();

			// Perform the Query
			$objDatabase->NonQuery('
				TRUNCATE `articlecore`');
		}

		/**
		 * Reload this Articlecore from the database.
		 * @return void
		 */
		public function Reload() {
			// Make sure we are actually Restored from the database
			if (!$this->__blnRestored)
				throw new QCallerException('Cannot call Reload() on a new, unsaved Articlecore object.');

			// Reload the Object
			$objReloaded = Articlecore::Load($this->intId);

			// Update $this's local variables to match
			$this->strAsin = $objReloaded->strAsin;
			$this->strDetailPageURL = $objReloaded->strDetailPageURL;
			$this->strBinding = $objReloaded->strBinding;
			$this->strTitle = $objReloaded->strTitle;
			$this->ProductGroup = $objReloaded->ProductGroup;
			$this->strImageURL = $objReloaded->strImageURL;
		}



		////////////////////
		// PUBLIC OVERRIDERS
		////////////////////

				/**
		 * Override method to perform a property "Get"
		 * This will get the value of $strName
		 *
		 * @param string $strName Name of the property to get
		 * @return mixed
		 */
		public function __get($strName) {
			switch ($strName) {
				///////////////////
				// Member Variables
				///////////////////
				case 'Id':
					/**
					 * Gets the value for intId (Read-Only PK)
					 * @return integer
					 */
					return $this->intId;

				case 'Asin':
					/**
					 * Gets the value for strAsin 
					 * @return string
					 */
					return $this->strAsin;

				case 'DetailPageURL':
					/**
					 * Gets the value for strDetailPageURL 
					 * @return string
					 */
					return $this->strDetailPageURL;

				case 'Binding':
					/**
					 * Gets the value for strBinding 
					 * @return string
					 */
					return $this->strBinding;

				case 'Title':
					/**
					 * Gets the value for strTitle 
					 * @return string
					 */
					return $this->strTitle;

				case 'ProductGroup':
					/**
					 * Gets the value for intProductGroup 
					 * @return integer
					 */
					return $this->intProductGroup;

				case 'ImageURL':
					/**
					 * Gets the value for strImageURL 
					 * @return string
					 */
					return $this->strImageURL;


				///////////////////
				// Member Objects
				///////////////////
				case 'ProductGroupObject':
					/**
					 * Gets the value for the Articlecategory object referenced by intProductGroup 
					 * @return Articlecategory
					 */
					try {
						if ((!$this->objProductGroupObject) && (!is_null($this->intProductGroup)))
							$this->objProductGroupObject = Articlecategory::Load($this->intProductGroup);
						return $this->objProductGroupObject;
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}


				////////////////////////////
				// Virtual Object References (Many to Many and Reverse References)
				// (If restored via a "Many-to" expansion)
				////////////////////////////

				case '_ArticlebookAsReferenceID':
					/**
					 * Gets the value for the private _objArticlebookAsReferenceID (Read-Only)
					 * if set due to an expansion on the articlebook.ReferenceID reverse relationship
					 * @return Articlebook
					 */
					return $this->_objArticlebookAsReferenceID;

				case '_ArticlebookAsReferenceIDArray':
					/**
					 * Gets the value for the private _objArticlebookAsReferenceIDArray (Read-Only)
					 * if set due to an ExpandAsArray on the articlebook.ReferenceID reverse relationship
					 * @return Articlebook[]
					 */
					return (array) $this->_objArticlebookAsReferenceIDArray;

				case '_ArticlemoviesAsReferenceID':
					/**
					 * Gets the value for the private _objArticlemoviesAsReferenceID (Read-Only)
					 * if set due to an expansion on the articlemovies.ReferenceID reverse relationship
					 * @return Articlemovies
					 */
					return $this->_objArticlemoviesAsReferenceID;

				case '_ArticlemoviesAsReferenceIDArray':
					/**
					 * Gets the value for the private _objArticlemoviesAsReferenceIDArray (Read-Only)
					 * if set due to an ExpandAsArray on the articlemovies.ReferenceID reverse relationship
					 * @return Articlemovies[]
					 */
					return (array) $this->_objArticlemoviesAsReferenceIDArray;

				case '_ArticlemusicAsReferenceID':
					/**
					 * Gets the value for the private _objArticlemusicAsReferenceID (Read-Only)
					 * if set due to an expansion on the articlemusic.ReferenceID reverse relationship
					 * @return Articlemusic
					 */
					return $this->_objArticlemusicAsReferenceID;

				case '_ArticlemusicAsReferenceIDArray':
					/**
					 * Gets the value for the private _objArticlemusicAsReferenceIDArray (Read-Only)
					 * if set due to an ExpandAsArray on the articlemusic.ReferenceID reverse relationship
					 * @return Articlemusic[]
					 */
					return (array) $this->_objArticlemusicAsReferenceIDArray;


				case '__Restored':
					return $this->__blnRestored;

				default:
					try {
						return parent::__get($strName);
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}
			}
		}

				/**
		 * Override method to perform a property "Set"
		 * This will set the property $strName to be $mixValue
		 *
		 * @param string $strName Name of the property to set
		 * @param string $mixValue New value of the property
		 * @return mixed
		 */
		public function __set($strName, $mixValue) {
			switch ($strName) {
				///////////////////
				// Member Variables
				///////////////////
				case 'Asin':
					/**
					 * Sets the value for strAsin 
					 * @param string $mixValue
					 * @return string
					 */
					try {
						return ($this->strAsin = QType::Cast($mixValue, QType::String));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'DetailPageURL':
					/**
					 * Sets the value for strDetailPageURL 
					 * @param string $mixValue
					 * @return string
					 */
					try {
						return ($this->strDetailPageURL = QType::Cast($mixValue, QType::String));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'Binding':
					/**
					 * Sets the value for strBinding 
					 * @param string $mixValue
					 * @return string
					 */
					try {
						return ($this->strBinding = QType::Cast($mixValue, QType::String));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'Title':
					/**
					 * Sets the value for strTitle 
					 * @param string $mixValue
					 * @return string
					 */
					try {
						return ($this->strTitle = QType::Cast($mixValue, QType::String));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'ProductGroup':
					/**
					 * Sets the value for intProductGroup 
					 * @param integer $mixValue
					 * @return integer
					 */
					try {
						$this->objProductGroupObject = null;
						return ($this->intProductGroup = QType::Cast($mixValue, QType::Integer));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'ImageURL':
					/**
					 * Sets the value for strImageURL 
					 * @param string $mixValue
					 * @return string
					 */
					try {
						return ($this->strImageURL = QType::Cast($mixValue, QType::String));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}


				///////////////////
				// Member Objects
				///////////////////
				case 'ProductGroupObject':
					/**
					 * Sets the value for the Articlecategory object referenced by intProductGroup 
					 * @param Articlecategory $mixValue
					 * @return Articlecategory
					 */
					if (is_null($mixValue)) {
						$this->intProductGroup = null;
						$this->objProductGroupObject = null;
						return null;
					} else {
						// Make sure $mixValue actually is a Articlecategory object
						try {
							$mixValue = QType::Cast($mixValue, 'Articlecategory');
						} catch (QInvalidCastException $objExc) {
							$objExc->IncrementOffset();
							throw $objExc;
						} 

						// Make sure $mixValue is a SAVED Articlecategory object
						if (is_null($mixValue->Id))
							throw new QCallerException('Unable to set an unsaved ProductGroupObject for this Articlecore');

						// Update Local Member Variables
						$this->objProductGroupObject = $mixValue;
						$this->intProductGroup = $mixValue->Id;

						// Return $mixValue
						return $mixValue;
					}
					break;

				default:
					try {
						return parent::__set($strName, $mixValue);
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}
			}
		}

		/**
		 * Lookup a VirtualAttribute value (if applicable).  Returns NULL if none found.
		 * @param string $strName
		 * @return string
		 */
		public function GetVirtualAttribute($strName) {
			if (array_key_exists($strName, $this->__strVirtualAttributeArray))
				return $this->__strVirtualAttributeArray[$strName];
			return null;
		}



		///////////////////////////////
		// ASSOCIATED OBJECTS' METHODS
		///////////////////////////////

			
		
		// Related Objects' Methods for ArticlebookAsReferenceID
		//-------------------------------------------------------------------

		/**
		 * Gets all associated ArticlebooksAsReferenceID as an array of Articlebook objects
		 * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
		 * @return Articlebook[]
		*/ 
		public function GetArticlebookAsReferenceIDArray($objOptionalClauses = null) {
			if ((is_null($this->intId)))
				return array();

			try {
				return Articlebook::LoadArrayByReferenceID($this->intId, $objOptionalClauses);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}

		/**
		 * Counts all associated ArticlebooksAsReferenceID
		 * @return int
		*/ 
		public function CountArticlebooksAsReferenceID() {
			if ((is_null($this->intId)))
				return 0;

			return Articlebook::CountByReferenceID($this->intId);
		}

		/**
		 * Associates a ArticlebookAsReferenceID
		 * @param Articlebook $objArticlebook
		 * @return void
		*/ 
		public function AssociateArticlebookAsReferenceID(Articlebook $objArticlebook) {
			if ((is_null($this->intId)))
				throw new QUndefinedPrimaryKeyException('Unable to call AssociateArticlebookAsReferenceID on this unsaved Articlecore.');
			if ((is_null($objArticlebook->Id)))
				throw new QUndefinedPrimaryKeyException('Unable to call AssociateArticlebookAsReferenceID on this Articlecore with an unsaved Articlebook.');

			// Get the Database Object for this Class
			$objDatabase = Articlecore::GetDatabase();

			// Perform the SQL Query
			$objDatabase->NonQuery('
				UPDATE
					`articlebook`
				SET
					`ReferenceID` = ' . $objDatabase->SqlVariable($this->intId) . '
				WHERE
					`id` = ' . $objDatabase->SqlVariable($objArticlebook->Id) . '
			');
		}

		/**
		 * Unassociates a ArticlebookAsReferenceID
		 * @param Articlebook $objArticlebook
		 * @return void
		*/ 
		public function UnassociateArticlebookAsReferenceID(Articlebook $objArticlebook) {
			if ((is_null($this->intId)))
				throw new QUndefinedPrimaryKeyException('Unable to call UnassociateArticlebookAsReferenceID on this unsaved Articlecore.');
			if ((is_null($objArticlebook->Id)))
				throw new QUndefinedPrimaryKeyException('Unable to call UnassociateArticlebookAsReferenceID on this Articlecore with an unsaved Articlebook.');

			// Get the Database Object for this Class
			$objDatabase = Articlecore::GetDatabase();

			// Perform the SQL Query
			$objDatabase->NonQuery('
				UPDATE
					`articlebook`
				SET
					`ReferenceID` = null
				WHERE
					`id` = ' . $objDatabase->SqlVariable($objArticlebook->Id) . ' AND
					`ReferenceID` = ' . $objDatabase->SqlVariable($this->intId) . '
			');
		}

		/**
		 * Unassociates all ArticlebooksAsReferenceID
		 * @return void
		*/ 
		public function UnassociateAllArticlebooksAsReferenceID() {
			if ((is_null($this->intId)))
				throw new QUndefinedPrimaryKeyException('Unable to call UnassociateArticlebookAsReferenceID on this unsaved Articlecore.');

			// Get the Database Object for this Class
			$objDatabase = Articlecore::GetDatabase();

			// Perform the SQL Query
			$objDatabase->NonQuery('
				UPDATE
					`articlebook`
				SET
					`ReferenceID` = null
				WHERE
					`ReferenceID` = ' . $objDatabase->SqlVariable($this->intId) . '
			');
		}

		/**
		 * Deletes an associated ArticlebookAsReferenceID
		 * @param Articlebook $objArticlebook
		 * @return void
		*/ 
		public function DeleteAssociatedArticlebookAsReferenceID(Articlebook $objArticlebook) {
			if ((is_null($this->intId)))
				throw new QUndefinedPrimaryKeyException('Unable to call UnassociateArticlebookAsReferenceID on this unsaved Articlecore.');
			if ((is_null($objArticlebook->Id)))
				throw new QUndefinedPrimaryKeyException('Unable to call UnassociateArticlebookAsReferenceID on this Articlecore with an unsaved Articlebook.');

			// Get the Database Object for this Class
			$objDatabase = Articlecore::GetDatabase();

			// Perform the SQL Query
			$objDatabase->NonQuery('
				DELETE FROM
					`articlebook`
				WHERE
					`id` = ' . $objDatabase->SqlVariable($objArticlebook->Id) . ' AND
					`ReferenceID` = ' . $objDatabase->SqlVariable($this->intId) . '
			');
		}

		/**
		 * Deletes all associated ArticlebooksAsReferenceID
		 * @return void
		*/ 
		public function DeleteAllArticlebooksAsReferenceID() {
			if ((is_null($this->intId)))
				throw new QUndefinedPrimaryKeyException('Unable to call UnassociateArticlebookAsReferenceID on this unsaved Articlecore.');

			// Get the Database Object for this Class
			$objDatabase = Articlecore::GetDatabase();

			// Perform the SQL Query
			$objDatabase->NonQuery('
				DELETE FROM
					`articlebook`
				WHERE
					`ReferenceID` = ' . $objDatabase->SqlVariable($this->intId) . '
			');
		}

			
		
		// Related Objects' Methods for ArticlemoviesAsReferenceID
		//-------------------------------------------------------------------

		/**
		 * Gets all associated ArticlemoviesesAsReferenceID as an array of Articlemovies objects
		 * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
		 * @return Articlemovies[]
		*/ 
		public function GetArticlemoviesAsReferenceIDArray($objOptionalClauses = null) {
			if ((is_null($this->intId)))
				return array();

			try {
				return Articlemovies::LoadArrayByReferenceID($this->intId, $objOptionalClauses);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}

		/**
		 * Counts all associated ArticlemoviesesAsReferenceID
		 * @return int
		*/ 
		public function CountArticlemoviesesAsReferenceID() {
			if ((is_null($this->intId)))
				return 0;

			return Articlemovies::CountByReferenceID($this->intId);
		}

		/**
		 * Associates a ArticlemoviesAsReferenceID
		 * @param Articlemovies $objArticlemovies
		 * @return void
		*/ 
		public function AssociateArticlemoviesAsReferenceID(Articlemovies $objArticlemovies) {
			if ((is_null($this->intId)))
				throw new QUndefinedPrimaryKeyException('Unable to call AssociateArticlemoviesAsReferenceID on this unsaved Articlecore.');
			if ((is_null($objArticlemovies->Id)))
				throw new QUndefinedPrimaryKeyException('Unable to call AssociateArticlemoviesAsReferenceID on this Articlecore with an unsaved Articlemovies.');

			// Get the Database Object for this Class
			$objDatabase = Articlecore::GetDatabase();

			// Perform the SQL Query
			$objDatabase->NonQuery('
				UPDATE
					`articlemovies`
				SET
					`ReferenceID` = ' . $objDatabase->SqlVariable($this->intId) . '
				WHERE
					`id` = ' . $objDatabase->SqlVariable($objArticlemovies->Id) . '
			');
		}

		/**
		 * Unassociates a ArticlemoviesAsReferenceID
		 * @param Articlemovies $objArticlemovies
		 * @return void
		*/ 
		public function UnassociateArticlemoviesAsReferenceID(Articlemovies $objArticlemovies) {
			if ((is_null($this->intId)))
				throw new QUndefinedPrimaryKeyException('Unable to call UnassociateArticlemoviesAsReferenceID on this unsaved Articlecore.');
			if ((is_null($objArticlemovies->Id)))
				throw new QUndefinedPrimaryKeyException('Unable to call UnassociateArticlemoviesAsReferenceID on this Articlecore with an unsaved Articlemovies.');

			// Get the Database Object for this Class
			$objDatabase = Articlecore::GetDatabase();

			// Perform the SQL Query
			$objDatabase->NonQuery('
				UPDATE
					`articlemovies`
				SET
					`ReferenceID` = null
				WHERE
					`id` = ' . $objDatabase->SqlVariable($objArticlemovies->Id) . ' AND
					`ReferenceID` = ' . $objDatabase->SqlVariable($this->intId) . '
			');
		}

		/**
		 * Unassociates all ArticlemoviesesAsReferenceID
		 * @return void
		*/ 
		public function UnassociateAllArticlemoviesesAsReferenceID() {
			if ((is_null($this->intId)))
				throw new QUndefinedPrimaryKeyException('Unable to call UnassociateArticlemoviesAsReferenceID on this unsaved Articlecore.');

			// Get the Database Object for this Class
			$objDatabase = Articlecore::GetDatabase();

			// Perform the SQL Query
			$objDatabase->NonQuery('
				UPDATE
					`articlemovies`
				SET
					`ReferenceID` = null
				WHERE
					`ReferenceID` = ' . $objDatabase->SqlVariable($this->intId) . '
			');
		}

		/**
		 * Deletes an associated ArticlemoviesAsReferenceID
		 * @param Articlemovies $objArticlemovies
		 * @return void
		*/ 
		public function DeleteAssociatedArticlemoviesAsReferenceID(Articlemovies $objArticlemovies) {
			if ((is_null($this->intId)))
				throw new QUndefinedPrimaryKeyException('Unable to call UnassociateArticlemoviesAsReferenceID on this unsaved Articlecore.');
			if ((is_null($objArticlemovies->Id)))
				throw new QUndefinedPrimaryKeyException('Unable to call UnassociateArticlemoviesAsReferenceID on this Articlecore with an unsaved Articlemovies.');

			// Get the Database Object for this Class
			$objDatabase = Articlecore::GetDatabase();

			// Perform the SQL Query
			$objDatabase->NonQuery('
				DELETE FROM
					`articlemovies`
				WHERE
					`id` = ' . $objDatabase->SqlVariable($objArticlemovies->Id) . ' AND
					`ReferenceID` = ' . $objDatabase->SqlVariable($this->intId) . '
			');
		}

		/**
		 * Deletes all associated ArticlemoviesesAsReferenceID
		 * @return void
		*/ 
		public function DeleteAllArticlemoviesesAsReferenceID() {
			if ((is_null($this->intId)))
				throw new QUndefinedPrimaryKeyException('Unable to call UnassociateArticlemoviesAsReferenceID on this unsaved Articlecore.');

			// Get the Database Object for this Class
			$objDatabase = Articlecore::GetDatabase();

			// Perform the SQL Query
			$objDatabase->NonQuery('
				DELETE FROM
					`articlemovies`
				WHERE
					`ReferenceID` = ' . $objDatabase->SqlVariable($this->intId) . '
			');
		}

			
		
		// Related Objects' Methods for ArticlemusicAsReferenceID
		//-------------------------------------------------------------------

		/**
		 * Gets all associated ArticlemusicsAsReferenceID as an array of Articlemusic objects
		 * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
		 * @return Articlemusic[]
		*/ 
		public function GetArticlemusicAsReferenceIDArray($objOptionalClauses = null) {
			if ((is_null($this->intId)))
				return array();

			try {
				return Articlemusic::LoadArrayByReferenceID($this->intId, $objOptionalClauses);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}

		/**
		 * Counts all associated ArticlemusicsAsReferenceID
		 * @return int
		*/ 
		public function CountArticlemusicsAsReferenceID() {
			if ((is_null($this->intId)))
				return 0;

			return Articlemusic::CountByReferenceID($this->intId);
		}

		/**
		 * Associates a ArticlemusicAsReferenceID
		 * @param Articlemusic $objArticlemusic
		 * @return void
		*/ 
		public function AssociateArticlemusicAsReferenceID(Articlemusic $objArticlemusic) {
			if ((is_null($this->intId)))
				throw new QUndefinedPrimaryKeyException('Unable to call AssociateArticlemusicAsReferenceID on this unsaved Articlecore.');
			if ((is_null($objArticlemusic->Id)))
				throw new QUndefinedPrimaryKeyException('Unable to call AssociateArticlemusicAsReferenceID on this Articlecore with an unsaved Articlemusic.');

			// Get the Database Object for this Class
			$objDatabase = Articlecore::GetDatabase();

			// Perform the SQL Query
			$objDatabase->NonQuery('
				UPDATE
					`articlemusic`
				SET
					`ReferenceID` = ' . $objDatabase->SqlVariable($this->intId) . '
				WHERE
					`id` = ' . $objDatabase->SqlVariable($objArticlemusic->Id) . '
			');
		}

		/**
		 * Unassociates a ArticlemusicAsReferenceID
		 * @param Articlemusic $objArticlemusic
		 * @return void
		*/ 
		public function UnassociateArticlemusicAsReferenceID(Articlemusic $objArticlemusic) {
			if ((is_null($this->intId)))
				throw new QUndefinedPrimaryKeyException('Unable to call UnassociateArticlemusicAsReferenceID on this unsaved Articlecore.');
			if ((is_null($objArticlemusic->Id)))
				throw new QUndefinedPrimaryKeyException('Unable to call UnassociateArticlemusicAsReferenceID on this Articlecore with an unsaved Articlemusic.');

			// Get the Database Object for this Class
			$objDatabase = Articlecore::GetDatabase();

			// Perform the SQL Query
			$objDatabase->NonQuery('
				UPDATE
					`articlemusic`
				SET
					`ReferenceID` = null
				WHERE
					`id` = ' . $objDatabase->SqlVariable($objArticlemusic->Id) . ' AND
					`ReferenceID` = ' . $objDatabase->SqlVariable($this->intId) . '
			');
		}

		/**
		 * Unassociates all ArticlemusicsAsReferenceID
		 * @return void
		*/ 
		public function UnassociateAllArticlemusicsAsReferenceID() {
			if ((is_null($this->intId)))
				throw new QUndefinedPrimaryKeyException('Unable to call UnassociateArticlemusicAsReferenceID on this unsaved Articlecore.');

			// Get the Database Object for this Class
			$objDatabase = Articlecore::GetDatabase();

			// Perform the SQL Query
			$objDatabase->NonQuery('
				UPDATE
					`articlemusic`
				SET
					`ReferenceID` = null
				WHERE
					`ReferenceID` = ' . $objDatabase->SqlVariable($this->intId) . '
			');
		}

		/**
		 * Deletes an associated ArticlemusicAsReferenceID
		 * @param Articlemusic $objArticlemusic
		 * @return void
		*/ 
		public function DeleteAssociatedArticlemusicAsReferenceID(Articlemusic $objArticlemusic) {
			if ((is_null($this->intId)))
				throw new QUndefinedPrimaryKeyException('Unable to call UnassociateArticlemusicAsReferenceID on this unsaved Articlecore.');
			if ((is_null($objArticlemusic->Id)))
				throw new QUndefinedPrimaryKeyException('Unable to call UnassociateArticlemusicAsReferenceID on this Articlecore with an unsaved Articlemusic.');

			// Get the Database Object for this Class
			$objDatabase = Articlecore::GetDatabase();

			// Perform the SQL Query
			$objDatabase->NonQuery('
				DELETE FROM
					`articlemusic`
				WHERE
					`id` = ' . $objDatabase->SqlVariable($objArticlemusic->Id) . ' AND
					`ReferenceID` = ' . $objDatabase->SqlVariable($this->intId) . '
			');
		}

		/**
		 * Deletes all associated ArticlemusicsAsReferenceID
		 * @return void
		*/ 
		public function DeleteAllArticlemusicsAsReferenceID() {
			if ((is_null($this->intId)))
				throw new QUndefinedPrimaryKeyException('Unable to call UnassociateArticlemusicAsReferenceID on this unsaved Articlecore.');

			// Get the Database Object for this Class
			$objDatabase = Articlecore::GetDatabase();

			// Perform the SQL Query
			$objDatabase->NonQuery('
				DELETE FROM
					`articlemusic`
				WHERE
					`ReferenceID` = ' . $objDatabase->SqlVariable($this->intId) . '
			');
		}





		////////////////////////////////////////
		// METHODS for SOAP-BASED WEB SERVICES
		////////////////////////////////////////

		public static function GetSoapComplexTypeXml() {
			$strToReturn = '<complexType name="Articlecore"><sequence>';
			$strToReturn .= '<element name="Id" type="xsd:int"/>';
			$strToReturn .= '<element name="Asin" type="xsd:string"/>';
			$strToReturn .= '<element name="DetailPageURL" type="xsd:string"/>';
			$strToReturn .= '<element name="Binding" type="xsd:string"/>';
			$strToReturn .= '<element name="Title" type="xsd:string"/>';
			$strToReturn .= '<element name="ProductGroupObject" type="xsd1:Articlecategory"/>';
			$strToReturn .= '<element name="ImageURL" type="xsd:string"/>';
			$strToReturn .= '<element name="__blnRestored" type="xsd:boolean"/>';
			$strToReturn .= '</sequence></complexType>';
			return $strToReturn;
		}

		public static function AlterSoapComplexTypeArray(&$strComplexTypeArray) {
			if (!array_key_exists('Articlecore', $strComplexTypeArray)) {
				$strComplexTypeArray['Articlecore'] = Articlecore::GetSoapComplexTypeXml();
				Articlecategory::AlterSoapComplexTypeArray($strComplexTypeArray);
			}
		}

		public static function GetArrayFromSoapArray($objSoapArray) {
			$objArrayToReturn = array();

			foreach ($objSoapArray as $objSoapObject)
				array_push($objArrayToReturn, Articlecore::GetObjectFromSoapObject($objSoapObject));

			return $objArrayToReturn;
		}

		public static function GetObjectFromSoapObject($objSoapObject) {
			$objToReturn = new Articlecore();
			if (property_exists($objSoapObject, 'Id'))
				$objToReturn->intId = $objSoapObject->Id;
			if (property_exists($objSoapObject, 'Asin'))
				$objToReturn->strAsin = $objSoapObject->Asin;
			if (property_exists($objSoapObject, 'DetailPageURL'))
				$objToReturn->strDetailPageURL = $objSoapObject->DetailPageURL;
			if (property_exists($objSoapObject, 'Binding'))
				$objToReturn->strBinding = $objSoapObject->Binding;
			if (property_exists($objSoapObject, 'Title'))
				$objToReturn->strTitle = $objSoapObject->Title;
			if ((property_exists($objSoapObject, 'ProductGroupObject')) &&
				($objSoapObject->ProductGroupObject))
				$objToReturn->ProductGroupObject = Articlecategory::GetObjectFromSoapObject($objSoapObject->ProductGroupObject);
			if (property_exists($objSoapObject, 'ImageURL'))
				$objToReturn->strImageURL = $objSoapObject->ImageURL;
			if (property_exists($objSoapObject, '__blnRestored'))
				$objToReturn->__blnRestored = $objSoapObject->__blnRestored;
			return $objToReturn;
		}

		public static function GetSoapArrayFromArray($objArray) {
			if (!$objArray)
				return null;

			$objArrayToReturn = array();

			foreach ($objArray as $objObject)
				array_push($objArrayToReturn, Articlecore::GetSoapObjectFromObject($objObject, true));

			return unserialize(serialize($objArrayToReturn));
		}

		public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects) {
			if ($objObject->objProductGroupObject)
				$objObject->objProductGroupObject = Articlecategory::GetSoapObjectFromObject($objObject->objProductGroupObject, false);
			else if (!$blnBindRelatedObjects)
				$objObject->intProductGroup = null;
			return $objObject;
		}




	}



	/////////////////////////////////////
	// ADDITIONAL CLASSES for QCODO QUERY
	/////////////////////////////////////

	class QQNodeArticlecore extends QQNode {
		protected $strTableName = 'articlecore';
		protected $strPrimaryKey = 'id';
		protected $strClassName = 'Articlecore';
		public function __get($strName) {
			switch ($strName) {
				case 'Id':
					return new QQNode('id', 'Id', 'integer', $this);
				case 'Asin':
					return new QQNode('ASIN', 'Asin', 'string', $this);
				case 'DetailPageURL':
					return new QQNode('DetailPageURL', 'DetailPageURL', 'string', $this);
				case 'Binding':
					return new QQNode('Binding', 'Binding', 'string', $this);
				case 'Title':
					return new QQNode('Title', 'Title', 'string', $this);
				case 'ProductGroup':
					return new QQNode('ProductGroup', 'ProductGroup', 'integer', $this);
				case 'ProductGroupObject':
					return new QQNodeArticlecategory('ProductGroup', 'ProductGroupObject', 'integer', $this);
				case 'ImageURL':
					return new QQNode('ImageURL', 'ImageURL', 'string', $this);
				case 'ArticlebookAsReferenceID':
					return new QQReverseReferenceNodeArticlebook($this, 'articlebookasreferenceid', 'reverse_reference', 'ReferenceID');
				case 'ArticlemoviesAsReferenceID':
					return new QQReverseReferenceNodeArticlemovies($this, 'articlemoviesasreferenceid', 'reverse_reference', 'ReferenceID');
				case 'ArticlemusicAsReferenceID':
					return new QQReverseReferenceNodeArticlemusic($this, 'articlemusicasreferenceid', 'reverse_reference', 'ReferenceID');

				case '_PrimaryKeyNode':
					return new QQNode('id', 'Id', 'integer', $this);
				default:
					try {
						return parent::__get($strName);
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}
			}
		}
	}

	class QQReverseReferenceNodeArticlecore extends QQReverseReferenceNode {
		protected $strTableName = 'articlecore';
		protected $strPrimaryKey = 'id';
		protected $strClassName = 'Articlecore';
		public function __get($strName) {
			switch ($strName) {
				case 'Id':
					return new QQNode('id', 'Id', 'integer', $this);
				case 'Asin':
					return new QQNode('ASIN', 'Asin', 'string', $this);
				case 'DetailPageURL':
					return new QQNode('DetailPageURL', 'DetailPageURL', 'string', $this);
				case 'Binding':
					return new QQNode('Binding', 'Binding', 'string', $this);
				case 'Title':
					return new QQNode('Title', 'Title', 'string', $this);
				case 'ProductGroup':
					return new QQNode('ProductGroup', 'ProductGroup', 'integer', $this);
				case 'ProductGroupObject':
					return new QQNodeArticlecategory('ProductGroup', 'ProductGroupObject', 'integer', $this);
				case 'ImageURL':
					return new QQNode('ImageURL', 'ImageURL', 'string', $this);
				case 'ArticlebookAsReferenceID':
					return new QQReverseReferenceNodeArticlebook($this, 'articlebookasreferenceid', 'reverse_reference', 'ReferenceID');
				case 'ArticlemoviesAsReferenceID':
					return new QQReverseReferenceNodeArticlemovies($this, 'articlemoviesasreferenceid', 'reverse_reference', 'ReferenceID');
				case 'ArticlemusicAsReferenceID':
					return new QQReverseReferenceNodeArticlemusic($this, 'articlemusicasreferenceid', 'reverse_reference', 'ReferenceID');

				case '_PrimaryKeyNode':
					return new QQNode('id', 'Id', 'integer', $this);
				default:
					try {
						return parent::__get($strName);
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}
			}
		}
	}

?>